﻿using System;
using System.Drawing;
using System.Windows.Forms;

namespace TestesFixacao.WindowsApp.Refatorado.Controls.Shared
{
    public partial class BaseDialog : Form
    {
        protected bool _configurando;

        public BaseDialog()
        {
            InitializeComponent();
        }

        protected string DescricaoTela
        {
            set
            {
                labelTitulo.Text += value;
                Text += value;
            }
        }

        protected void RedimensionaJanela(Size size)
        {
            this.MinimumSize = size;
            this.MaximumSize = size;
        }

        protected void DesabilitaBotaoOk()
        {
            btnOk.Enabled = false;
        }

        protected void HabilitaBotaoOk()
        {
            btnOk.Enabled = true;
        }

        protected void RegistraControles(params Control[] controles)
        {
            foreach (Control item in controles)
            {
                if (item is RadioButton)
                    ((RadioButton)item).CheckedChanged += ValueChangedControl;
                else
                    item.TextChanged += ValueChangedControl;
            }
        }

        private void BaseDialog_FormClosing(object sender, FormClosingEventArgs e)
        {
            Main.Instance.ShowMessageInFooter(string.Empty);
        }

        private void ValueChangedControl(object sender, EventArgs e)
        {
            DoOperation();
        }

        protected virtual void DoOperation()
        {
        }
    }
}